from lib.redis import client as redis


class ReportQueueService:
	REPORT_FOR_STORAGE = '_report_for_storage'
	REPORT_FOR_COMPUTE = '_report_for_compute'
	REPORT_FOR_VELOCITY = '_report_for_velocity'

	@staticmethod
	def push(k, data):
		redis.rpush(k, data)

	@staticmethod
	def pop(k):
		return redis.lpop(k)

	@staticmethod
	def last(k):
		return redis.get(k)

	@staticmethod
	def set_last(k, data):
		return redis.set(k, data, 2)

	@staticmethod
	def publish(k, data):
		redis.publish(k, data)

	@staticmethod
	def listen(k):
		p = redis.pubsub(ignore_subscribe_messages=True)
		p.subscribe(k)
		return p
